﻿<UserControl x:Class="VMWareLabWorkflowsDataContracts.VMWareLabDetailsDialogControls.EnvironmentDetailsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Converters="clr-namespace:VMWareLabWorkflowsDataContracts.VMWareLabDetailsDialogControls.Commands"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="500" Background="LightGray">
    <UserControl.Resources>
        <Converters:InvertableBooleanToVisibilityConverter x:Key="VisibilityConverter"/>
    </UserControl.Resources>
    <Grid Margin="12,12,12,12" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" HorizontalAlignment="Left" Name="textBlock7" Text="Connect to the VMWare vSphere Server to select the virtual machines." VerticalAlignment="Top" Margin="0,0,0,20"/>
        <TextBlock Grid.Row="1" HorizontalAlignment="Left" Name="textBlock1" Text="VMWare vSphere Server URL:" VerticalAlignment="Top" />
        <TextBox Grid.Row="2" HorizontalAlignment="Left" Name="tbServerName" VerticalAlignment="Top" Width="415" Text="{Binding VmWareLabEnvironmentDetails.ServerName}"/>
        <TextBlock Grid.Row="3" HorizontalAlignment="Left" Name="textBlock2" Text="User Name:" VerticalAlignment="Top" Margin="0,5,0,0"/>
        <TextBox Grid.Row="4" HorizontalAlignment="Left" Name="tbUserName" VerticalAlignment="Top" Width="415" Text="{Binding VmWareLabEnvironmentDetails.UserName}"/>
        <TextBlock Grid.Row="5" HorizontalAlignment="Left" Name="textBlock3" Text="Password:" VerticalAlignment="Top" Margin="0,5,0,0"/>
        <PasswordBox Grid.Row="6" HorizontalAlignment="Left" Name="tbPassword" VerticalAlignment="Top" Width="415" PasswordChanged="tbPassword_PasswordChanged" />
        <Grid Grid.Row="7" HorizontalAlignment="Left" VerticalAlignment="Top" Width="180" Margin="215,15,0,5">
            <TextBlock  HorizontalAlignment="Stretch" VerticalAlignment="Center" TextAlignment="Right" Text="{Binding Path=ConnectionStatus}"></TextBlock>
        </Grid>
        <Button Content="Connect" Grid.Row="7" Height="23" HorizontalAlignment="Left" Margin="0,10,0,15" Name="btnConnect" VerticalAlignment="Top" Width="75" Command="{Binding ConnectToVirtualMachine}" />
        <Image Grid.Row="7" Grid.RowSpan="2" Height="16" HorizontalAlignment="Left" Margin="400,13,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="16" Source="/VMWareLabWorkflowsDataContracts;component/Images/check.png" 
               Visibility="{Binding IsConnected, Converter={StaticResource VisibilityConverter}, ConverterParameter=Normal}"/>
        <Image Grid.Row="7" Grid.RowSpan="2" Height="16" HorizontalAlignment="Left" Margin="400,13,0,0" Name="image2" Stretch="Fill" VerticalAlignment="Top" Width="16" Source="/VMWareLabWorkflowsDataContracts;component/Images/forbidden.png" 
               Visibility="{Binding IsConnected, Converter={StaticResource VisibilityConverter}, ConverterParameter=Inverted}"/>
        <Grid Grid.Row="8" IsEnabled="{Binding Path=IsConnected}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" HorizontalAlignment="Left" Name="textBlock5" Text="Available virtual machines:" VerticalAlignment="Top" Margin="0,5,0,0"/>
            <TextBlock Grid.Row="2" HorizontalAlignment="Left" Name="textBlock6" Text="Selected virtual machines:" VerticalAlignment="Top" Margin="0,10,0,0"/>
            <DataGrid Grid.Row="1" HorizontalAlignment="Left" Name="dgAvailableVMs" VerticalAlignment="Stretch" Width="415" Height="100" ItemsSource="{Binding Path=AvailableVirtualMachines}" SelectedItem="{Binding Path=CurrentVmAvailable, Mode=TwoWay}"
                      AutoGenerateColumns="False"
                      CanUserAddRows="False"
                      CanUserDeleteRows="False"
                      CanUserSortColumns="False"
                      CanUserReorderColumns="False"
                      AlternatingRowBackground="WhiteSmoke"
                      RowHeaderWidth="16" 
                      Validation.ErrorTemplate="{x:Null}"
                      GridLinesVisibility="None">
                <DataGrid.Columns>
                    <DataGridTextColumn
                        Header="Virtual Machine Name"
                        Binding="{Binding VirtualMachineName}"
                        CanUserReorder="True"
                        IsReadOnly="True"
                        CanUserSort="False"
                            Width="*"/>
                </DataGrid.Columns>
            </DataGrid>

            <!--<ListBox Grid.Row="1" HorizontalAlignment="Left" Name="lbSelectedVMs" VerticalAlignment="Stretch" Width="192" Margin="223,0,0,0" ItemsSource="{Binding Path=SelectedVirtualMachines}" SelectedItem="{Binding Path=CurrentVmSelected, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>-->

            <DataGrid
                x:Name="dgSelectedVirtualMachines"
                Width="415"
                Height="100"
                Margin="0,0,0,0"
                Grid.Row="3"
                ItemsSource="{Binding SelectedVirtualMachines}"
                SelectedItem="{Binding Path=CurrentVmSelected}"
                AutoGenerateColumns="False"
                CanUserAddRows="False"
                CanUserDeleteRows="False"
                CanUserSortColumns="False"
                CanUserReorderColumns="False"
                AlternatingRowBackground="WhiteSmoke"
                RowHeaderWidth="16" 
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Validation.ErrorTemplate="{x:Null}"
                GridLinesVisibility="None">
                <DataGrid.Columns>
                    <DataGridTextColumn
                        Header="Virtual Machine Name"
                        Binding="{Binding VirtualMachineName}"
                        CanUserReorder="True"
                        IsReadOnly="True"
                        CanUserSort="False"
                            Width="Auto"/>

                    <DataGridComboBoxColumn
                        Header="Revert to Snapshot" 
                        CanUserReorder="True"
                        IsReadOnly="False"
                        CanUserSort="False"
                        SelectedItemBinding="{Binding SelectedSnapshotName}"
                            Width="*">
                        <DataGridComboBoxColumn.ElementStyle>
                            <Style TargetType="ComboBox">
                                <Setter Property="ItemsSource" Value="{Binding SnapshotNames}"/>
                                <Setter Property="IsReadOnly" Value="True"/>
                            </Style>
                        </DataGridComboBoxColumn.ElementStyle>
                        <DataGridComboBoxColumn.EditingElementStyle>
                            <Style TargetType="ComboBox">
                                <Setter Property="ItemsSource" Value="{Binding SnapshotNames}"/>
                            </Style>
                        </DataGridComboBoxColumn.EditingElementStyle>
                    </DataGridComboBoxColumn>
                </DataGrid.Columns>
            </DataGrid>

            <Button Grid.Row="1" Content="Add" Height="23" HorizontalAlignment="Left" Margin="421,0,0,0" Name="btnAdd" VerticalAlignment="Top" Width="50" Command="{Binding AddEnvironment}">
            </Button>
            <Button Height="23" Content="Remove" HorizontalAlignment="Left" Margin="421,0,0,95" Name="btnRemove" VerticalAlignment="Bottom" Width="50" Grid.Row="3" Command="{Binding RemoveEnvironment}">
            </Button>
        </Grid>
        <CheckBox Content="Revert to a specific snapshot of the environments" Grid.Row="9" Height="16" HorizontalAlignment="Left" Name="cbReverToSnapshot"
                  VerticalAlignment="Top" Margin="0,5,0,0" IsChecked="{Binding VmWareLabEnvironmentDetails.RevertToSnapshot}"/>
    </Grid>
</UserControl>
